<template>
  <div class="app-container">
    <el-form :model="searchForm" :inline="true">
      <el-row>
        <el-col :span="19">
          <el-form-item>
            <el-input v-model="searchForm.offerId" placeholder="关联报价单号" clearable @keyup.enter.native="handleSearch" />
          </el-form-item>
          <el-form-item>
            <el-input v-model="searchForm.projectName" placeholder="项目名称" clearable @keyup.enter.native="handleSearch" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" class="iconfont icon-chaxun1" @click="handleSearch"> 查询</el-button>
          </el-form-item>
        </el-col>
        <el-col :span="5" class="search-right">
          <el-button type="text" icon="el-icon-plus" @click="createOfferMonitor">创建项目及方案</el-button>
          <el-button type="text" icon="el-icon-refresh" @click="handleSearch">刷新</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      border
      :data="offermonitorData"
      stripe
      highlight-current-row
      :header-cell-style="{background:'#ECF3FC'}"
    >
      <el-table-column type="index" width="50" label="序号" align="center" />
      <el-table-column prop="projectName" label="项目名称" width="140px" align="center" />
      <el-table-column prop="sourceStatus" label="项目来源" width="130" align="center">
        <template slot-scope="{row}">
          <span v-if="row.sourceStatus === '3'">监测方案</span>
          <span v-if="row.sourceStatus === '4'">报价单</span>
        </template>
      </el-table-column>
      <el-table-column prop="offerId" label="关联报价单号" width="190px" align="center" />
      <el-table-column label="项目操作" align="center" width="130px">
        <template slot-scope="{row}">
          <el-button type="text" @click="addOfferMonitorScheme(row)">新增方案</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="jcfamc" label="监测方案名称" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" v-if="element.monitorName === null || element.monitorName === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
              <el-button type="text" v-if="element.monitorName != null && element.monitorName != ''" style="color: #606266;cursor: default;">{{ element.monitorName }}</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="glrwdh" label="关联任务单号" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-tooltip effect="dark" placement="top" v-if="element.relationTaskCode != null && element.relationTaskCode != ''">
                <div slot="content" style="max-width: 210px">
                  {{ element.relationTaskCode}}<el-button type="text">&nbsp;</el-button>
                </div>
                <div class="apostrophe">
                  <span>{{ element.relationTaskCode}}<el-button type="text">&nbsp;</el-button></span>
                </div>
              </el-tooltip>
              <el-button type="text" v-if="element.relationTaskCode === null || element.relationTaskCode === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="fazt" label="方案状态" width="120px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <span v-if="element.schemeType === '0'"><el-button type="text" style="color: #fff;cursor: default;background-color: #909399;padding-left: 5px;padding-right: 5px;">待编辑</el-button></span>
              <span v-if="element.schemeType === '1'"><el-button type="text" style="color: #fff;cursor: default;background-color: #1890ff;padding-left: 5px;padding-right: 5px;">待评审</el-button></span>
              <span v-if="element.schemeType === '2'"><el-button type="text" style="color: #fff;cursor: default;background-color: rgb(255, 73, 73);padding-left: 5px;padding-right: 5px;">驳回</el-button></span>
              <span v-if="element.schemeType === '3'"><el-button type="text" style="color: #fff;cursor: default;background-color: rgb(17, 185, 92);padding-left: 5px;padding-right: 5px;">评审通过</el-button></span>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="fashr" label="方案审核人" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-tooltip effect="dark" placement="top" v-if="element.reviewerUserName != null && element.reviewerUserName != ''">
                <div slot="content" style="max-width: 210px">
                  {{ element.reviewerUserName}}<el-button type="text">&nbsp;</el-button>
                </div>
                <div class="apostrophe">
                  <span>{{ element.reviewerUserName}}<el-button type="text">&nbsp;</el-button></span>
                </div>
              </el-tooltip>
              <el-button type="text" v-if="element.reviewerUserName === null || element.reviewerUserName === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="fabzr" label="方案编制人" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" style="color: #606266;cursor: default;">{{ element.schemeUserName }}</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column prop="cjsj" label="创建时间" width="170px" align="center">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" style="color: #606266;cursor: default;">{{ element.createTime }}</el-button>
            </div>
          </div>
        </div>
      </el-table-column>
      <el-table-column label="操作" fixed="right" align="center" width="260px">
        <div slot-scope="{row}">
          <div v-for="element in row.offerInfoMonitorDetailVos">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-button type="text" v-if="element.schemeType === '0' || element.schemeType === '2'" @click="updateOfferMonitorScheme(element, row)">编辑</el-button>
              <el-button type="text" @click="copyOfferInfosMonitorScheme(element.id)">复制</el-button>
              <el-button type="text" v-if="element.schemeType === '0' || element.schemeType === '2'" @click="submitOfferInfoMonitorUser(element)">提交评审</el-button>
              <el-button type="text" v-if="(element.schemeType === '0' || element.schemeType === '2') && element.schemeUserId === monSchemeUserId" @click="deleteOfferInfosMonitorScheme(element.id)">删除</el-button>
              <!-- 更多 -->
              <el-dropdown size="medium">
              <span class="el-dropdown-link">
                更多<i class="el-icon-arrow-down el-icon--right" />
              </span>
                <el-dropdown-menu slot="dropdown">
                  <el-link :underline="false" v-if="element.schemeType === '1' || element.schemeType === '2'" @click="findReviewSchedule(element)">
                    <el-dropdown-item>评审进度查看</el-dropdown-item>
                  </el-link>
                  <el-link style="text-align:center" :underline="false" v-if="element.schemeType === '0' || element.schemeType === '2'">
                    <el-dropdown-item>
                      <el-upload class="upload-demo"
                        :show-file-list="false"
                        :data="{'monitorSchemeId': element.id}"
                        action="/api/offermonitor/uploadMonitorSchemeFile"
                        :on-change="onUploadMonitorSchemeChange"
                        accept=".doc,.docx,.pdf,.xls,.xlsx">上传方案</el-upload>
                    </el-dropdown-item>
                  </el-link>
                  <el-link :underline="false" @click="downloadMonScheme(element)">
                    <el-dropdown-item>原始方案下载</el-dropdown-item>
                  </el-link>
                  <el-link :underline="false" @click="downloadMonSchemeLast(element)">
                    <el-dropdown-item>最新方案下载</el-dropdown-item>
                  </el-link>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </div>
        </div>
      </el-table-column>
    </el-table>
    <div style="float: right">
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="searchForm.pageNumber"
        :limit.sync="searchForm.pageSize"
        @pagination="handleSearch"/>
    </div>

<!-- *************************************** 创建项目及方案 ***************************************************-->

    <el-dialog :title="'创建项目及方案'" :visible.sync="orderDialogVisible" :before-close="handleDialogClose" fullscreen center>
      <el-form ref="orderForm" :model="orderForm" :rules="orderRules">
        <!-- 基础信息 -->
        <el-card shadow="never">
          <div slot="header">
            <span>项目基础信息<i class="el-input__icon" /></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.projectName" label="项目名称:" label-width="100px">
                <el-input v-model="orderForm.offerInfoTdo.projectName" placeholder="项目名称" maxlength="30" show-word-limit />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorName" label="委托单位:" label-width="100px">
                <el-select
                  v-model="orderForm.offerInfoTdo.consignorName"
                  filterable
                  remote
                  placeholder="委托单位"
                  :remote-method="querySearchAsync"
                  style="width: 100%;"
                  @change="handleSelectCom"
                >
                  <el-option
                    v-for="item in Object.keys(companyMap)"
                    :key="item"
                    :label="companyMap[item]"
                    :value="item"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorLinker" label="委托人:" label-width="110px">
                <el-input v-model="orderForm.offerInfoTdo.consignorLinker" placeholder="委托人" maxlength="10" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorLinkerPhone" label="联系电话:" label-width="100px">
                <el-input v-model="orderForm.offerInfoTdo.consignorLinkerPhone" placeholder="联系电话" maxlength="15" />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.certificationType" label="认证类型:" label-width="100px">
                <el-select v-model="orderForm.offerInfoTdo.certificationType" style="width: 100%;" placeholder="检测类型">
                  <el-option value="1" label="CMA" />
                  <el-option value="2" label="CNAS" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="检测类型:" prop="offerInfoTdo.checkType" label-width="110px">
                <el-select v-model="orderForm.offerInfoTdo.checkType" placeholder="请选择类型" style="width: 100%;">
                  <el-option label="委托检测" value="0" />
                  <el-option label="客户送检" value="1" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item  prop="offerInfoTdo.appointUserId" label="指定业务员:" label-width="100px">
                <el-select style="width: 100%;" v-model="orderForm.offerInfoTdo.appointUserId" clearable placeholder="请选择指定业务员" @change="getsUserId">
                  <el-option
                    v-for="item in userIdArray"
                    :key="item.userId"
                    :label="item.empName"
                    :value="item.userId"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="客户要求项目完成日期:" prop="offerInfoTdo.finishDate" label-width="184px">
                <el-date-picker
                  v-model="orderForm.offerInfoTdo.finishDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  style="width: 115%;"
                  placeholder="客户要求项目完成日期"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item prop="offerInfoTdo.projectAddress" label="项目地址:" label-width="100px">
                <div style="width: 100%;">
                  <el-select
                    v-model="provinceOne"
                    placeholder="请选择省"
                    style="width: 12%;"
                    @change="getSubRegionByRegionCode('cityArray', $event)">
                    <el-option
                      v-for="item in provinceArray"
                      :key="item.regionCode"
                      :label="item.regionName"
                      :value="item.regionCode"/>
                  </el-select>
                  <el-select
                    v-model="cityOne"
                    placeholder="请选择市"
                    style="width: 12%;"
                    @change="getSubRegionByRegionCode('areaArray', $event)">
                    <el-option
                      v-for="item in cityArray"
                      :key="item.regionCode"
                      :label="item.regionName"
                      :value="item.regionCode"/>
                  </el-select>
                  <el-select
                    v-model="countyOne"
                    style="width: 12%;"
                    placeholder="请选择区">
                    <el-option
                      v-for="item in areaArray"
                      :key="item.regionCode"
                      :label="item.regionName"
                      :value="item.regionCode"/>
                  </el-select>
                  <el-input style="width: 28.5%;" v-model="orderForm.offerInfoTdo.projectAddress" placeholder="请录入详细地址"  />
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="110px">
                <span slot="label">
                  备注
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="该备注信息可展示给业务负责人和调度负责人查看"
                  >
                    <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                  </el-popover>
                  :
                </span>
                <el-input v-model="orderForm.offerInfoTdo.remark" type="textarea" :rows="2" show-word-limit placeholder="备注" maxlength="100" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="110px">
                <span slot="label">
                  说明
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="该说明信息会自动填充到生成的报价单中，位于报价单下方的说明框"
                  >
                    <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                  </el-popover>
                  :
                </span>
                <el-input v-model="orderForm.offerInfoTdo.explains" type="textarea" :rows="2" show-word-limit placeholder="说明" maxlength="100" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <!-- 监测方案信息 -->
        <el-card shadow="never">
          <div slot="header">
            <span>监测方案信息<i class="el-input__icon" /></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.monitorName" label="监测方案名称:" label-width="120px">
                <el-input v-model="orderForm.offerInfoTdo.monitorName" placeholder="监测方案名称" maxlength="30"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item  prop="offerInfoTdo.relationTaskCode" label="关联任务单号:" label-width="120px">
                <el-select style="width: 100%;" v-model="orderForm.offerInfoTdo.relationTaskCode" clearable placeholder="请选择关联任务单号">
                </el-select>
              </el-form-item>
            </el-col>
<!--            <el-col :span="8">-->
<!--              <el-form-item label="方案上传:" label-width="120px">-->
<!--                <el-upload-->
<!--                  ref="upload"-->
<!--                  drag-->
<!--                  class="upload-demo"-->
<!--                  action="/api/offermonitor/uploadMonitor"-->
<!--                  :on-change="onUploadChange"-->
<!--                  :on-exceed="onExceed"-->
<!--                  :on-remove="onUploadRemove"-->
<!--                  :limit="1"-->
<!--                  accept=".doc,.docx,.pdf,.xls,.xlsx">-->
<!--                  <div class="el-upload__text" style="margin-top: 4px;">将文件拖到此处，或<em>点击上传</em></div>-->
<!--                  <div slot="tip" class="el-upload__tip" style="color:red;margin-top: -15px;margin-bottom: -15px;">-->
<!--                    注：您只能上传.doc,.docx,.pdf,.xls,.xlsx格式的文件-->
<!--                  </div>-->
<!--                </el-upload>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
          </el-row>
        </el-card>
        <!-- 监测计划信息 -->
        <el-card shadow="never" style="margin-top:10px;padding-bottom: 10px">
          <div slot="header" class="clearfix">
            <span>监测计划信息<i class="el-input__icon" /></span>
            <el-button style="float: right; margin:4px 2px;" type="primary" plain size="mini" @click="addPlanInfo">新增计划</el-button>
          </div>
          <el-table
            :data="orderForm.offerPlanTdos"
            stripe
            border
            highlight-current-row
            :header-cell-style="{background:'#ECF3FC'}"
            max-height="400px"
          >
            <el-table-column type="index" label="序号" width="60" align="center" />
            <el-table-column label="计划名称" align="center">
              <template slot-scope="{row}">
                <el-input v-model="row.planName" placeholder="" />
              </template>
            </el-table-column>
            <el-table-column prop="checkFreq" label="监测频次" align="center" />
            <el-table-column prop="execTimes" label="计划执行次数" align="center" />
            <el-table-column prop="planTime" label="计划时长" align="center" />
            <el-table-column prop="checkFactorCnt" label="检测因子数" align="center" />
            <el-table-column prop="index" label="操作" align="center">
              <template slot-scope="{$index, row}">
                <el-button type="text" size="mini" @click="planSearch(row)">查看</el-button>
                <el-button type="text" size="mini" @click="planUpdate(row)">编辑</el-button>
                <el-button type="text" size="mini" @click="planDelete($index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmDialog">保存</el-button>
      </div>
    </el-dialog>

<!-- ****************************************** 编辑方案 ************************************************-->

    <el-dialog :title="'编辑方案'" :visible.sync="orderDialogUpdateVisible" :before-close="handleDialogClose" fullscreen center>
      <el-form ref="orderUpdateForm" :model="orderForm" :rules="orderUpdateRules">
        <!-- 基础信息 -->
        <el-card shadow="never">
          <div slot="header">
            <span>项目基础信息<i class="el-input__icon" /></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.projectName" label="项目名称:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.projectName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorName" label="委托单位:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.consignorName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorLinker" label="委托人:" label-width="110px">
                <span>{{orderForm.offerInfoTdo.consignorLinker}}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorLinkerPhone" label="联系电话:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.consignorLinkerPhone}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.certificationType" label="认证类型:" label-width="100px">
                <span v-if="this.orderForm.offerInfoTdo.certificationType === '1'">CMA</span>
                <span v-if="this.orderForm.offerInfoTdo.certificationType === '2'">CNAS</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="检测类型:" prop="offerInfoTdo.checkType" label-width="110px">
                <span v-if="this.orderForm.offerInfoTdo.checkType === '0'">委托检测</span>
                <span v-if="this.orderForm.offerInfoTdo.checkType === '1'">客户送检</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" v-if="sourceStatus !== '4'">
              <el-form-item  prop="offerInfoTdo.appointUserId" label="指定业务员:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.appointUserName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="客户要求项目完成日期:" prop="offerInfoTdo.finishDate" label-width="184px">
                <span>{{orderForm.offerInfoTdo.finishDate}}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24" v-if="sourceStatus !== '4'">
              <el-form-item prop="offerInfoTdo.projectAddress" label="项目地址:" label-width="100px">
                <div style="width: 100%;">
                  <span>
                    {{orderForm.offerInfoTdo.provinceName}}
                    {{orderForm.offerInfoTdo.cityName}}
                    {{orderForm.offerInfoTdo.countyName}}
                    {{orderForm.offerInfoTdo.projectAddress}}
                  </span>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="110px">
                <span slot="label">
                  备注
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="该备注信息可展示给业务负责人和调度负责人查看"
                  >
                    <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                  </el-popover>
                  :
                </span>
                <span>{{orderForm.offerInfoTdo.remark}}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="110px">
                <span slot="label">
                  说明
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="该说明信息会自动填充到生成的报价单中，位于报价单下方的说明框"
                  >
                    <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                  </el-popover>
                  :
                </span>
                <span>{{orderForm.offerInfoTdo.explains}}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <!-- 监测方案信息 -->
        <el-card shadow="never">
          <div slot="header">
            <span>监测方案信息<i class="el-input__icon" /></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.monitorName" label="监测方案名称:" label-width="120px">
                <el-input v-model="orderForm.offerInfoTdo.monitorName" placeholder="监测方案名称" maxlength="30"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
                 <el-form-item  prop="offerInfoTdo.relationTaskCode" label="关联任务单号:" label-width="120px">
                     <el-select style="width: 100%;" v-model="relationTaskCodeUpdate" multiple clearable placeholder="请选择关联任务单号" @change="getsTaskCode">
                          <el-option
                              v-for="item in taskCodeArray"
                              :key="item.jobId"
                              :label="item.jobName"
                              :value="item.jobId"
                          />
                     </el-select>
                 </el-form-item>
            </el-col>
<!--            <el-col :span="8">-->
<!--              <el-form-item label="方案上传:" label-width="120px">-->
<!--                <el-upload-->
<!--                  ref="uploadUpdate"-->
<!--                  drag-->
<!--                  class="upload-demo"-->
<!--                  action="/api/offermonitor/uploadMonitor"-->
<!--                  :on-change="onUploadChange"-->
<!--                  :on-exceed="onExceed"-->
<!--                  :on-remove="onUploadRemove"-->
<!--                  :limit="1"-->
<!--                  accept=".doc,.docx,.pdf,.xls,.xlsx">-->
<!--                  <div class="el-upload__text" style="margin-top: 4px;">将文件拖到此处，或<em>点击上传</em></div>-->
<!--                  <div slot="tip" class="el-upload__tip" style="color:red;margin-top: -15px;margin-bottom: -15px;">-->
<!--                    注：您只能上传.doc,.docx,.pdf,.xls,.xlsx格式的文件-->
<!--                  </div>-->
<!--                </el-upload>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
          </el-row>
        </el-card>
        <!-- 监测计划信息 -->
        <el-card shadow="never" style="margin-top:10px;padding-bottom: 10px">
          <div slot="header" class="clearfix">
            <span>监测计划信息<i class="el-input__icon" /></span>
            <el-button style="float: right; margin:4px 2px;" type="primary" plain size="mini" @click="addPlanInfo">新增计划</el-button>
          </div>
          <el-table
            :data="orderForm.offerPlanTdos"
            stripe
            border
            highlight-current-row
            :header-cell-style="{background:'#ECF3FC'}"
            max-height="400px"
          >
            <el-table-column type="index" label="序号" width="60" align="center" />
            <el-table-column label="计划名称" align="center">
              <template slot-scope="{row}">
                <el-input v-model="row.planName" placeholder="" />
              </template>
            </el-table-column>
            <el-table-column prop="checkFreq" label="监测频次" align="center" />
            <el-table-column prop="execTimes" label="计划执行次数" align="center" />
            <el-table-column prop="planTime" label="计划时长" align="center" />
            <el-table-column prop="checkFactorCnt" label="检测因子数" align="center" />
            <el-table-column prop="index" label="操作" align="center">
              <template slot-scope="{$index, row}">
                <el-button type="text" size="mini" @click="planSearch(row)">查看</el-button>
                <el-button type="text" size="mini" @click="planUpdate(row)">编辑</el-button>
                <el-button type="text" size="mini" @click="planDelete($index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogUpdateVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmUpdateDialog">保存</el-button>
      </div>
    </el-dialog>

<!-- ****************************************** 新增监测方案(只添加方案，不添加项目) ************************************************-->

    <el-dialog :title="'新增方案'" :visible.sync="orderDialogAddVisible" :before-close="handleDialogClose" fullscreen center>
      <el-form ref="orderAddForm" :model="orderForm" :rules="orderAddRules">
        <!-- 基础信息 -->
        <el-card shadow="never">
          <div slot="header">
            <span>项目基础信息<i class="el-input__icon" /></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.projectName" label="项目名称:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.projectName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorName" label="委托单位:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.consignorName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorLinker" label="委托人:" label-width="110px">
                <span>{{orderForm.offerInfoTdo.consignorLinker}}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.consignorLinkerPhone" label="联系电话:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.consignorLinkerPhone}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.certificationType" label="认证类型:" label-width="100px">
                <span v-if="this.orderForm.offerInfoTdo.certificationType === '1'">CMA</span>
                <span v-if="this.orderForm.offerInfoTdo.certificationType === '2'">CNAS</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="检测类型:" prop="offerInfoTdo.checkType" label-width="110px">
                <span v-if="this.orderForm.offerInfoTdo.checkType === '0'">委托检测</span>
                <span v-if="this.orderForm.offerInfoTdo.checkType === '1'">客户送检</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="8" v-if="sourceStatus !== '4'">
              <el-form-item  prop="offerInfoTdo.appointUserId" label="指定业务员:" label-width="100px">
                <span>{{orderForm.offerInfoTdo.appointUserName}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="客户要求项目完成日期:" prop="offerInfoTdo.finishDate" label-width="184px">
                <span>{{orderForm.offerInfoTdo.finishDate}}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24" v-if="sourceStatus !== '4'">
              <el-form-item prop="offerInfoTdo.projectAddress" label="项目地址:" label-width="100px">
                <div style="width: 100%;">
                  <span>
                    {{orderForm.offerInfoTdo.provinceName}}
                    {{orderForm.offerInfoTdo.cityName}}
                    {{orderForm.offerInfoTdo.countyName}}
                    {{orderForm.offerInfoTdo.projectAddress}}
                  </span>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="110px">
                <span slot="label">
                  备注
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="该备注信息可展示给业务负责人和调度负责人查看"
                  >
                    <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                  </el-popover>
                  :
                </span>
                <span>{{orderForm.offerInfoTdo.remark}}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="110px">
                <span slot="label">
                  说明
                  <el-popover
                    placement="top-start"
                    title=""
                    width="300"
                    trigger="hover"
                    content="该说明信息会自动填充到生成的报价单中，位于报价单下方的说明框"
                  >
                    <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                  </el-popover>
                  :
                </span>
                <span>{{orderForm.offerInfoTdo.explains}}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
        <!-- 监测方案信息 -->
        <el-card shadow="never">
          <div slot="header">
            <span>监测方案信息<i class="el-input__icon" /></span>
          </div>
          <el-row>
            <el-col :span="8">
              <el-form-item prop="offerInfoTdo.monitorName" label="监测方案名称:" label-width="120px">
                <el-input v-model="orderForm.offerInfoTdo.monitorName" placeholder="监测方案名称" maxlength="30"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item  prop="offerInfoTdo.relationTaskCode" label="关联任务单号:" label-width="120px">
                <el-select style="width: 100%;" v-model="relationTaskCodeUpdate" multiple clearable placeholder="请选择关联任务单号" @change="getsTaskCode">
                  <el-option
                    v-for="item in taskCodeArray"
                    :key="item.jobId"
                    :label="item.jobName"
                    :value="item.jobId"
                  />
                </el-select>
              </el-form-item>
            </el-col>
<!--            <el-col :span="8">-->
<!--              <el-form-item label="方案上传:" label-width="120px">-->
<!--                <el-upload-->
<!--                  ref="uploadAdd"-->
<!--                  drag-->
<!--                  class="upload-demo"-->
<!--                  action="/api/offermonitor/uploadMonitor"-->
<!--                  :on-change="onUploadChange"-->
<!--                  :on-exceed="onExceed"-->
<!--                  :on-remove="onUploadRemove"-->
<!--                  :limit="1"-->
<!--                  accept=".doc,.docx,.pdf,.xls,.xlsx">-->
<!--                  <div class="el-upload__text" style="margin-top: 4px;">将文件拖到此处，或<em>点击上传</em></div>-->
<!--                  <div slot="tip" class="el-upload__tip" style="color:red;margin-top: -15px;margin-bottom: -15px;">-->
<!--                    注：您只能上传.doc,.docx,.pdf,.xls,.xlsx格式的文件-->
<!--                  </div>-->
<!--                </el-upload>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
          </el-row>
        </el-card>
        <!-- 监测计划信息 -->
        <el-card shadow="never" style="margin-top:10px;padding-bottom: 10px">
          <div slot="header" class="clearfix">
            <span>监测计划信息<i class="el-input__icon" /></span>
            <el-button style="float: right; margin:4px 2px;" type="primary" plain size="mini" @click="addPlanInfo">新增计划</el-button>
          </div>
          <el-table
            :data="orderForm.offerPlanTdos"
            stripe
            border
            highlight-current-row
            :header-cell-style="{background:'#ECF3FC'}"
            max-height="400px"
          >
            <el-table-column type="index" label="序号" width="60" align="center" />
            <el-table-column label="计划名称" align="center">
              <template slot-scope="{row}">
                <el-input v-model="row.planName" placeholder="" />
              </template>
            </el-table-column>
            <el-table-column prop="checkFreq" label="监测频次" align="center" />
            <el-table-column prop="execTimes" label="计划执行次数" align="center" />
            <el-table-column prop="planTime" label="计划时长" align="center" />
            <el-table-column prop="checkFactorCnt" label="检测因子数" align="center" />
            <el-table-column prop="index" label="操作" align="center">
              <template slot-scope="{$index, row}">
                <el-button type="text" size="mini" @click="planSearch(row)">查看</el-button>
                <el-button type="text" size="mini" @click="planUpdate(row)">编辑</el-button>
                <el-button type="text" size="mini" @click="planDelete($index)">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="orderDialogAddVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmAddDialog">保存</el-button>
      </div>
    </el-dialog>

<!-- *********************************************************************************************************-->

    <!-- 新增计划列表 -->
    <el-dialog :visible.sync="planInfoVisible" title="新增计划" append-to-body fullscreen :close-on-click-modal="false">
      <el-form :model="planForm" inline>
        <el-row>
          <el-col :span="6">
            <el-form-item label="计划名称:">
              <el-input v-model="planForm.planName" placeholder="计划名称" />
            </el-form-item>
          </el-col>
          <el-col :span="18">
            <el-form-item>
              <span slot="label">
                选择监测频次
                <el-popover
                  placement="top-start"
                  title=""
                  width="300"
                  trigger="hover"
                  content="监测计划的频次"
                >
                  <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                </el-popover>
                :
              </span>
              <el-select v-model="planForm.checkFreq" placeholder="选择监测频次" @change="reflushTime">
                <el-option
                  v-for="item in checkFreqArray"
                  :key="item.desc"
                  :label="item.desc"
                  :value="item.desc"
                />
              </el-select>
            </el-form-item>
            <el-form-item>
              <span slot="label">
                计划执行次数
                <el-popover
                  placement="top-start"
                  title=""
                  width="300"
                  trigger="hover"
                  content="该监测计划一共需要执行的总次数"
                >
                  <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
                </el-popover>
                :
              </span>
              <el-input-number v-model="planForm.execTimes" :min="0" :step="1" :precision="0" :disabled="planForm.checkFreq === '单次'" controls-position="right" placeholder="计划执行次数" @change="reflushTime" />
            </el-form-item>
            <el-form-item v-show="planForm.planTime.length > 0" label="计划时长:">
              {{ planForm.planTime }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-card shadow="never" style="width: 100%; min-height: 500px">
        <div slot="header" class="clearfix">
          <span>检测因子信息<i class="el-input__icon" /></span>
          <el-button style="float: right; margin:4px 2px;" type="primary" plain size="mini" @click="choseGroup">选择因子套餐</el-button>
          <el-button style="float: right; margin:4px 2px;" type="primary" plain size="mini" @click="addFactor">添加因子</el-button>
        </div>
        <el-table
          :data="planForm.factorTdoList"
          stripe
          border
          highlight-current-row
          show-summary
          :summary-method="getPlanSummaries"
          :header-cell-style="{background:'#ECF3FC'}"
          max-height="700px"
        >
          <template slot="empty">
            <div class="table_empty">
              <div class="empty_tips">
                <span>
                  暂无因子
                </span>
              </div>
            </div>
          </template>
          <el-table-column prop="factorPoint" label="检测位置" min-width="110" align="center">
            <template slot-scope="{row}">
              <el-input v-model="row.factorPoint" placeholder="请录入位置" />
            </template>
          </el-table-column>
          <el-table-column prop="className" label="检测对象" align="center" />
          <el-table-column prop="secdClassName" label="检测类别" align="center">
            <template slot-scope="{row}">
              <template v-if="row.meanName && row.meanName.length > 0">
                {{ row.secdClassName }}<span style="color:red">{{ '('+row.meanName+')' }}</span>
              </template>
              <template v-else>
                {{ row.secdClassName }}
              </template>
            </template>
          </el-table-column>
          <el-table-column prop="factorName" label="检测因子" align="center" />
          <el-table-column prop="standardNo" label="标准号" min-width="110px" align="center" />
          <el-table-column prop="standardName" label="标准名称" min-width="150px" align="center" />
          <el-table-column prop="dayCount" width="160px" align="center">
            <template slot="header">
              天数 <i class="el-input__icon " />
              <el-popover
                placement="top-start"
                title=""
                width="360"
                trigger="hover"
                content="该检测因子需要采集的天数"
              >
                <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
              </el-popover>
            </template>
            <template slot-scope="{row}">
              <el-input-number v-model="row.dayCount" size="small" style="width: 100%;" :disabled="row.secdClassId === '002001' || row.secdClassId === '002003'" :min="1" :step="1" :precision="0" controls-position="right" @change="reflushMoney(row)" />
            </template>
          </el-table-column>
          <el-table-column prop="frequency" width="160px" align="center">
            <template slot="header">
              频次(次/天) <i class="el-input__icon " />
              <el-popover
                placement="top-start"
                title=""
                width="360"
                trigger="hover"
                content="该检测因子每天需要采集的次数"
              >
                <svg-icon slot="reference" icon-class="help" style="font-size:16px" />
              </el-popover>
            </template>
            <template slot-scope="{row}">
              <el-input-number
                v-model="row.frequency"
                size="small"
                style="width: 100%;"
                :disabled="row.secdClassId === '002001' || row.secdClassId === '002003'"
                :min="1"
                :step="1"
                :max="row.secdClassId === '004001' || row.secdClassId === '004002' || row.secdClassId === '004003'
                  || row.secdClassId === '004004' || row.secdClassId === '004005'?0:10"
                :precision="0"
                controls-position="right"
                @change="reflushMoney(row)"
              />
            </template>
          </el-table-column>
          <el-table-column prop="totalNum" label="次数" width="100px" align="center">
            <template slot-scope="{row}">
              {{ Number(row.frequency * row.dayCount) }}
            </template>
          </el-table-column>
          <el-table-column align="center" label="操作">
            <template slot-scope="{$index, row}">
              <el-popover
                placement="left"
                width="280"
                trigger="click"
              >
                <el-input v-model="row.remark" placeholder="录入备注信息" />
                <el-button slot="reference" type="text">备注</el-button>
              </el-popover>
              <el-button style="margin-left: 10px;" type="text" @click="handleRowDel($index, row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button type="" @click="handleCancle">取消</el-button>
        <el-button type="primary" @click="confimPlanInfo">确认</el-button>
      </div>
    </el-dialog>

    <!-- 因子套餐 -->
    <el-dialog title="因子套餐" :visible.sync="factorGroupVisible" append-to-body :before-close="handleClearTabs" :close-on-click-modal="false" width="85%">
      <el-tabs v-model="activeName">
        <el-tab-pane label="同系因子套餐" name="1">
          <same-meal :clear-type="cleanAttr" @handleCancel="getTabStatus" @handleConfim="getTabResultForSame" />
        </el-tab-pane>
        <el-tab-pane label="自由因子套餐" name="2">
          <free-meal :clear-type="cleanAttr" @handleCancel="getTabStatus" @handleConfim="getTabResultForFree" />
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

    <!-- 添加因子信息 -->
    <el-dialog :visible.sync="factorVisible" append-to-body width="85%" :close-on-click-modal="false" top="5vh">
      <div>
        <el-row :gutter="10">
          <el-col :span="6">
            <el-card class="card-left" shadow="never">
              <div>
                <el-tree
                  ref="tree"
                  class="filter-tree"
                  :data="factorTreeData"
                  :props="defaultProps"
                  highlight-current
                  default-expand-all
                  :expand-on-click-node="true"
                  style="height: 100%;"
                  @node-click="handleTreeFactorSearch"
                />
              </div>
            </el-card>
          </el-col>
          <el-col :span="18">
            <el-container>
              <el-header height="45px">
                <el-input v-model.trim="factorForm.fuzzy" style="width:320px" placeholder="请输入因子/标准号/检测标准" @keyup.enter.native="handleFactorSearch" />
                <el-button type="primary" style="margin-left: 10px" @click="handleFactorSearch">查询</el-button>
              </el-header>
              <el-main class="main-body">
                <el-table
                  ref="multipleTable"
                  :data="showChoseData"
                  stripe
                  border
                  max-height="450px"
                  :header-cell-style="{background:'#ECF3FC'}"
                  @select="handleSelectChange"
                  @selection-change="handleSelectionChange"
                  :row-key="getRowKeys"
                >
                  <el-table-column type="selection" width="50" align="center" :reserve-selection="true" />
                  <el-table-column prop="className" label="检测对象" width="100px" align="center" />
                  <el-table-column prop="factorName" label="检测因子" align="center" />
                  <el-table-column prop="standardNo" label="标准号" align="center" />
                  <el-table-column prop="standardName" label="标准名称" min-width="130px" align="center" />
                  <el-table-column prop="analysisMethod" label="分析方法" align="center" />
                  <el-table-column prop="factorUnit" label="因子单位" width="80px" align="center" />
                  <el-table-column prop="cmaFlg" label="CMA" width="60px" align="center">
                    <template slot-scope="{row}">
                      <el-tag :type="row.cmaFlg==='1'?'success':'danger'">{{ row.cmaFlg==='1'?'Y':'N' }}</el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column prop="cnasFlg" label="CNAS" width="60px" align="center">
                    <template slot-scope="{row}">
                      <el-tag :type="row.cnasFlg==='1'?'success':'danger'">{{ row.cnasFlg==='1'?'Y':'N' }}</el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column prop="MoneyFormat" label="检测单价（元）" align="center">
                    <template slot-scope="{row}">
                      {{ row.price|MoneyFormat }} 元
                    </template>
                  </el-table-column>
                  <!--采样费-->
                  <el-table-column prop="collectPrice" label="采样费（元）" align="center">
                    <template slot-scope="{row}">
                      {{ row.collectPrice|MoneyFormat }} 元
                    </template>
                  </el-table-column>
                </el-table>
              </el-main>
              <el-footer height="45px">
                <pagination
                  v-show="factTotal>0"
                  :total="factTotal"
                  :page.sync="factorForm.pageNumber"
                  :limit.sync="factorForm.pageSize"
                  @pagination="handleFactorSearch"
                />
              </el-footer>
            </el-container>
          </el-col>
        </el-row>
        <el-divider content-position="left">已选因子</el-divider>
        <el-row style="min-height:36px;line-height: 30px">
          <el-col :span="2">
            <span>已选中因子:</span>
          </el-col>
          <el-col :span="22">
            <template v-if="choseFatcors && choseFatcors.length > 0">
              <el-tag
                v-for="item in choseFatcors"
                :key="item.id"
                closable
                :disable-transitions="false"
                style="margin:2px 3px"
                @close="handleClose(item)"
              >
                {{ item.factorName }}
              </el-tag>
            </template>
            <template v-else>
              无
            </template>
          </el-col>
        </el-row>
        <el-divider content-position="left">因子配置</el-divider>
        <el-form>
          <el-row :gutter="10">
            <el-col :span="6">
              <el-form-item v-if="currentNodeId === '002001'" label="均值类型:" label-width="100px">
                <el-select v-model="meanType" placeholder="请选择均值类型" @change="changeMeanType">
                  <el-option value="0" label="日均值" />
                  <el-option value="1" label="时均值" />
                  <el-option value="2" label="八小时均值" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="天数:" label-width="100px">
                <el-input-number v-model="setDay" controls-position="right" :min="1" :step="1" :precision="0" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="频次(次/天):" label-width="110px">
                <el-input-number v-model="frequency" :disabled="flag" controls-position="right" :max="maxTotal" :min="1" :step="1" :precision="0" />
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="addressArray && addressArray.length >0 ?'检测位置1:':'检测位置:'" label-width="100px">
                <el-input v-model="lookPosition" placeholder="检测位置" style="width: 250px;margin-right:3px" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col v-for="(item, index) in addressArray" :key="item.key" :span="24">
              <el-form-item :label="'检测位置'+(index+2)+':'" label-width="100px">
                <el-input v-model="item.value" placeholder="检测位置" style="width: 250px;margin-right:3px" />
                <el-button v-if="currentNodeId !== '002001' && currentNodeId !== '002003'" type="text" size="small" @click.prevent="removeAddDomain(item)">删除</el-button>
              </el-form-item>
            </el-col>
            <el-col v-if="currentNodeId !== '002003' && currentNodeId !== '002001'" :span="24" style="padding-left:20px">
              <el-form-item>
                <el-button type="primary" @click="addAddress">添加位置</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="factorVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmChoseFactor">确认</el-button>
      </div>
    </el-dialog>

    <!--  计划详情 -->
    <el-dialog title="计划详情" :visible.sync="planDetailVisible" append-to-body width="80%">
      <el-row style="height: 35px; font-size: 15px;">
        <el-col :span="8">
          计划名称: {{ showPlanForm.planName }}
        </el-col>
        <el-col :span="8">
          监测频次: {{ showPlanForm.checkFreq }}
        </el-col>
        <el-col :span="8">
          执行次数: {{ showPlanForm.execTimes }}
        </el-col>
      </el-row>
      <el-card shadow="never" style="width: 100%; min-height: 500px">
        <div slot="header" class="clearfix">
          <span>检测因子信息<i class="el-input__icon" /></span>
        </div>
        <el-table
          :data="showPlanForm.factorTdoList"
          stripe
          border
          highlight-current-row
          show-summary
          :summary-method="getPlanSummaries"
          :header-cell-style="{background:'#ECF3FC'}"
        >
          <template slot="empty">
            <div class="table_empty">
              <div class="empty_tips">
                <span>
                  暂无因子
                </span>
              </div>
            </div>
          </template>
          <el-table-column prop="factorPoint" label="检测位置" min-width="110" align="center" />
          <el-table-column prop="className" label="检测对象" align="center" />
          <el-table-column prop="secdClassName" label="检测类别" align="center">
            <template slot-scope="{row}">
              <template v-if="row.meanName && row.meanName.length > 0">
                {{ row.secdClassName }}<span style="color:red">{{ '('+row.meanName+')' }}</span>
              </template>
              <template v-else>
                {{ row.secdClassName }}
              </template>
            </template>
          </el-table-column>
          <el-table-column prop="factorName" label="检测因子" align="center" />
          <el-table-column prop="standardNo" label="标准号" min-width="110px" align="center" />
          <el-table-column prop="standardName" label="标准名称" min-width="150px" align="center" />
          <el-table-column prop="dayCount" label="天数" width="100px" align="center" />
          <el-table-column prop="frequency" label="频次(次/天)" width="100px" align="center" />
          <el-table-column prop="totalNum" label="次数" width="100px" align="center">
            <template slot-scope="{row}">
              {{ Number(row.dayCount * row.frequency).toFixed(0) }}
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </el-dialog>

    <!-- 提交评审 -->
    <el-dialog title="提交评审" :visible.sync="lookMonitorUserVisible" center width="50%" :close-on-click-modal="false">
      <div style="margin-bottom: 10px;">选择参与评审人员：</div>
      <el-table
        border
        :data="monitorUserData"
        stripe
        style="overflow: auto;"
        highlight-current-row
        :header-cell-style="{background:'#ECF3FC'}"
        @selection-change="handleUserSelectionChange"
      >
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column type="index" width="80" label="序号" align="center" />
        <el-table-column prop="empName" label="姓名" align="center" />
        <el-table-column prop="deptName" label="部门" align="center" />
        <el-table-column prop="roleNames" label="角色" align="center" />
      </el-table>
      <div slot="footer" class="dialog-footer" style="margin-top: -15px;">
        <el-button @click="lookMonitorUserVisible=false">取消</el-button>
        <el-button type="primary" @click="confirmMonitorUser">确认</el-button>
      </div>
    </el-dialog>

    <!-- 评审进度查看 -->
    <el-dialog title="评审进度查看" :visible.sync="seeMonitorUserVisible" center width="50%" :close-on-click-modal="false">
      <el-table
        border
        :data="reviewScheduleData"
        stripe
        style="overflow: auto;"
        highlight-current-row
        :header-cell-style="{background:'#ECF3FC'}"
      >
        <el-table-column prop="deviceStatus" label="评审结果" align="center">
          <template slot-scope="{row}">
            <span v-if="row.judgeStatus === '0'"><el-tag effect="dark" style="background: #82848a;border:none">暂未评审</el-tag></span>
            <span v-if="row.judgeStatus === '1'"><el-tag effect="dark" style="background: #13ce66;border:none">评审通过</el-tag></span>
            <span v-if="row.judgeStatus === '2'"><el-tag effect="dark" style="background: #ff4949;border:none">评审驳回</el-tag></span>
          </template>
        </el-table-column>
        <el-table-column prop="psyj" label="评审意见" width="170px" align="center">
          <div slot-scope="{row}">
              <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
                <el-tooltip effect="dark" placement="top" v-if="row.remark != null && row.remark != ''">
                  <div slot="content" style="max-width: 210px">
                    {{ row.remark}}<el-button type="text">&nbsp;</el-button>
                  </div>
                  <div class="apostrophe">
                    <span>{{ row.remark}}<el-button type="text">&nbsp;</el-button></span>
                  </div>
                </el-tooltip>
                <el-button type="text" v-if="row.remark === null || row.remark === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
              </div>
          </div>
        </el-table-column>
        <el-table-column prop="empName" label="姓名" align="center" />
        <el-table-column prop="deptName" label="部门" align="center" />
        <el-table-column prop="js" label="角色" width="170px" align="center">
          <div slot-scope="{row}">
            <div style="border:1px solid #e6ebf5;margin: -1px -11px -1px -11px;padding-top: 5px;padding-bottom: 2px;">
              <el-tooltip effect="dark" placement="top" v-if="row.roleNames != null && row.roleNames != ''">
                <div slot="content" style="max-width: 210px">
                  {{ row.roleNames}}<el-button type="text">&nbsp;</el-button>
                </div>
                <div class="apostrophe">
                  <span>{{ row.roleNames}}<el-button type="text">&nbsp;</el-button></span>
                </div>
              </el-tooltip>
              <el-button type="text" v-if="row.roleNames === null || row.roleNames === ''" style="color: #606266;cursor: default;">&nbsp;</el-button>
            </div>
          </div>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer" style="margin-top: -15px;">
        <el-button @click="seeMonitorUserVisible=false">取消</el-button>
        <el-button type="primary" @click="seeMonitorUserVisible=false">关闭</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import * as offermonitorServer from '@/api/offermonitor'
import * as orderServer from '@/api/offer'
import { uuid } from 'vue-uuid'
import * as factorServer from '@/api/factor'
import freeMeal from '@/views/order/components/freeMeal'
import sameMeal from '@/views/order/components/sameMeal'
import * as dictServer from '@/api/dict'

const MEAN_STATUS = {
  '0': '日均值',
  '1': '时均值',
  '2': '八小时均值'
}

export default {
  components: { Pagination, freeMeal, sameMeal },
  data() {
    return {
      searchForm: {
        offerId: '',
        projectName: '',
        pageNumber: 1,
        pageSize: 10
      },
      total: 0,
      offermonitorData: [],

      orderDialogVisible: false,
      orderForm: {
        monitorSchemeId: '',
        offerInfoTdo: {
          projectName: '',
          consignorName: '',
          consignorLinker: '',
          consignorLinkerPhone: '',
          finishDate: '',
          certificationType: '1',
          checkType: '0',
          offerType: '1',
          remark: '',
          explains: '',
          province: '',
          city: '',
          county: '',
          projectAddress: '',
          appointUserId: '',
          monitorName: '',
          relationTaskCode: null,
          monitorFileId: '',
          monitorNewFileId: '',
          secdClassId: ''
        },
        offerPlanTdos: [],
        offerCostTdo: {
          id: '',
          checkAmount: 0, // 检测费合计
          reportAmount: 0, // 报告编制费
          reportAmountRate: 10, // 报告编制费率
          expediteAmount: 0, // 报告加急费
          laborAmount: 0, // 人工费/采样费
          tripAmount: 0, // 差旅费
          taxAmount: '', // 增值税金额
          taxAmountRate: 6, // 增值税率
          sysAmount: 0, // 系统价格
          discountRate: '', // 检测优惠率
          draftAmount: 0 // 优惠价
        },
        selfCostTdos: []
      },
      orderRules: {
        offerInfoTdo: {
          projectName: [{ required: true, message: '请录入项目名称', trigger: 'blur' }],
          consignorName: [{ required: true, message: '请录入委托单位', trigger: 'blur' }],
          consignorLinker: [{ required: true, message: '请录入委托人', trigger: 'blur' }],
          consignorLinkerPhone: [{ required: true, message: '请录入联系方式', trigger: 'blur' }],
          appointUserId: [{ required: true, message: '请选择指定业务员', trigger: 'blur' }],
          finishDate: [{ required: true, message: '请选择客户要求项目完成日期', trigger: 'blur' }],
          projectAddress: [{ required: true, message: '地址信息不能为空', trigger: 'blur' }],
          monitorName: [{ required: true, message: '请录入监测方案名称', trigger: 'blur' }],
        }
      },
      companyMap: {},
      operEditType: false,
      currentRow: {},
      planInfoVisible: false,
      planForm: {
        planName: '',
        checkFreq: '',
        execTimes: 0,
        planTime: '',
        scheduleTimes: '',
        checkFactorCnt: 0,
        checkFee: '',
        sampFee: '',
        factorTdoList: []
      },
      checkFreqArray: [],
      currentUUid: '',
      cleanAttr: '',
      startFactorGroup: '',
      groupAddressArray: [],
      multiplGroupeSelection: [],
      factorGroupVisible: false,
      choseGroupFatcors: [], // 套餐因子选择
      activeName: '1',
      choseFatcors: [],
      multipleSelection: [],
      maxTotal: 10,
      currentNodeId: '',
      addressArray: [],
      setDay: 1,
      frequency: 1, // 频次
      lookPosition: '',
      meanType: '0',
      factorVisible: false,
      factorTreeData: [],
      defaultProps: {
        children: 'children',
        label: 'name',
        id: 'id'
      },
      flag: false,
      currentNodeName: '',
      factorForm: {
        fuzzy: '',
        classId: '',
        factorName: '',
        pageNumber: 1,
        pageSize: 10
      },
      showChoseData: [],
      factTotal: 0,
      MEAN_STATUS,
      planDetailVisible: false,
      showPlanForm: {},
      otherPrice: '',
      checkCostRate: '', // 检测优惠率
      provinceArray: [],
      cityArray: [],
      areaArray: [],
      provinceOne: '',
      cityOne: '',
      countyOne: '',
      userIdArray: [],
      taskCodeArray: [],
      orderDialogUpdateVisible: false,
      offerIdAddorUpdate: '',
      orderUpdateRules: {
        offerInfoTdo: {
          monitorName: [{ required: true, message: '请录入监测方案名称', trigger: 'blur' }],
        }
      },
      relationTaskCodeUpdate: null,

      monitorId: '',
      orderDialogAddVisible: false,
      orderAddRules: {
        offerInfoTdo: {
          monitorName: [{ required: true, message: '请录入监测方案名称', trigger: 'blur' }],
        }
      },

      monitorUserData: [],
      lookMonitorUserVisible: false,
      monitorUserId: [],
      monitorSchemeId: '',
      reviewScheduleData: [],
      seeMonitorUserVisible: false,
      sourceStatus: '',
      monSchemeUserId: '',

    }
  },

  computed: {
  },

  watch: {
    orderForm: {
      handler(val) {
        let t_checkAmount = 0.00 // 总检测费用   因子合计总费用 * 任务数
        let t_sampAmount = 0.00 // 总采样费   因子合计总采样费 * 任务数
        let t_reportAmount = 0.00 // 报告费用
        let t_expediteAmount = 0.00 // 加急费
        let t_taxAmount = 0.00 // 税率
        let t_tripAmount = 0.00 // 差旅费
        let t_laborAmount = 0.00 // 人工费
        let t_orderAmount = 0.00 // 其他费用
        let t_exTaxAmount = 0.00 // 除税费外总计
        // 计算计划单费用 == 因子检测总费用
        if (this.orderForm.offerPlanTdos.length > 0) {
          this.orderForm.offerPlanTdos.forEach(i => {
            t_checkAmount += parseFloat(i.checkFee * i.execTimes)
            t_sampAmount += parseFloat(i.sampFee * i.execTimes)
          })
          if (t_checkAmount > 0) {
            t_reportAmount = parseFloat(t_checkAmount * this.orderForm.offerCostTdo.reportAmountRate / 100)
          }
          t_tripAmount = parseFloat(this.orderForm.offerCostTdo.tripAmount)
          t_laborAmount = parseFloat(this.orderForm.offerCostTdo.laborAmount)
          t_expediteAmount = parseFloat(this.orderForm.offerCostTdo.expediteAmount)
          if (this.orderForm.selfCostTdos && this.orderForm.selfCostTdos.length > 0) {
            this.orderForm.selfCostTdos.forEach(j => {
              t_orderAmount += parseFloat(j.amount)
            })
          }
          // 不包含税费费用
          t_exTaxAmount = parseFloat(t_checkAmount + t_reportAmount + t_expediteAmount + t_tripAmount + t_laborAmount + t_orderAmount)
          t_taxAmount = parseFloat(t_exTaxAmount * this.orderForm.offerCostTdo.taxAmountRate / 100)
          this.orderForm.offerCostTdo.checkAmount = parseFloat(t_checkAmount).toFixed(2)
          if (this.offerRadio === '2'){
            // 采样费合计
            this.orderForm.offerCostTdo.laborAmount = parseFloat(t_sampAmount).toFixed(2)
          }
          this.orderForm.offerCostTdo.reportAmount = parseFloat(t_reportAmount).toFixed(2)
          this.orderForm.offerCostTdo.taxAmount = parseFloat(t_taxAmount).toFixed(2)
          this.otherPrice = parseFloat(t_orderAmount).toFixed(2)
          // this.checkCostRate = parseFloat((this.orderForm.offerCostTdo.sysAmount - this.orderForm.offerCostTdo.draftAmount) / this.orderForm.offerCostTdo.sysAmount * 100).toFixed(2)
          this.checkCostRate = parseFloat((t_checkAmount + this.orderForm.offerCostTdo.draftAmount - this.orderForm.offerCostTdo.sysAmount) / t_checkAmount * 100).toFixed(2)
          this.orderForm.offerCostTdo.sysAmount = parseFloat(t_exTaxAmount + t_taxAmount).toFixed(2)
        }
      },
      deep: true
    }
  },

  created() {
    this.getsUserId()
    this.getsTaskCode()
    this.getProvince()
    this.getFreqList()
    this.getTreeClassList()
    this.handleSearch()
  },

  methods: {
    handleSearch() {
      this.monSchemeUserId = this.$store.getters.userInfo.userId
      offermonitorServer.findOfferInfoMonitor(this.searchForm).then(res => {
        if (res.code === 200 && res.result) {
          this.offermonitorData = res.result.records || []
          this.total = res.result.total
        }
      })
    },
    // 指定业务员下拉选择
    getsUserId() {
      offermonitorServer.findMonitorAppointUser().then(res => {
        this.userIdArray = res.result || []
      })
    },
    // 关联任务单号下拉选择
    getsTaskCode() {
      const data = {offerId: this.offerIdAddorUpdate}
      offermonitorServer.findMonitorTaskCode(data).then(res => {
        this.taskCodeArray = res.result || []
      })
    },
    getProvince() {
      dictServer.getFirstLevel().then(res => {
        this.provinceArray = res.result;
      });
    },
    getSubRegionByRegionCode(type, regionCode) {
      if (regionCode === "cityArray") {
        this.cityOne = '';
        this.countyOne = '';
      } else {
        this.countyOne = '';
      }
      this.getRegionCode(type, regionCode);
    },
    getRegionCode(type, regionCode) {
      dictServer.getSubRegionByRegionCode(regionCode).then(res => {
        this[type] = res.result;
      });
    },
    getFreqList() {
      dictServer.findMonitorFreq().then(result => {
        if (result.code === 200) {
          this.checkFreqArray = result.result
        }
      })
    },
    getTreeClassList() {
      dictServer.findTreeClasses().then(res => {
        this.factorTreeData = res.result || []
      })
    },
    clearForm() {
      this.provinceOne = '';
      this.cityOne = '';
      this.countyOne = '';
      this.orderForm = {
        offerInfoTdo: {
          projectName: '',
          consignorName: '',
          consignorLinker: '',
          consignorLinkerPhone: '',
          finishDate: '',
          certificationType: '1',
          checkType: '0',
          offerType: '1',
          remark: '',
          explains: '',
          province: '',
          city: '',
          county: '',
          projectAddress: '',
          appointUserId: '',
          monitorName: '',
          relationTaskCode: null,
          monitorFileId: '',
          monitorNewFileId: '',
          secdClassId: ''
        },
        offerPlanTdos: [],
        offerCostTdo: {
          id: '',
          checkAmount: 0, // 检测费合计
          reportAmount: 0, // 报告编制费
          reportAmountRate: 10, // 报告编制费率
          expediteAmount: 0, // 报告加急费
          laborAmount: 0, // 人工费/采样费
          tripAmount: 0, // 差旅费
          taxAmount: '', // 增值税金额
          taxAmountRate: 6, // 增值税率
          sysAmount: 0, // 系统价格
          draftAmount: 0 // 优惠价
        },
        selfCostTdos: []
      }
    },
    onUploadChange(file) {
      if (file.status === 'ready') return
      if (file.status === 'success') {
        const res = file.response || {}
        if (res && res.code === 200) {
          this.orderForm.offerInfoTdo.monitorNewFileId = file.response.result
          this.$message({
            type: 'success',
            message: '上传成功!'
          })
        } else {
          this.$message.error('上传失败!')
        }
      } else {
        this.$message.error('上传失败!')
      }
    },
    onExceed() {
      this.$message.error('最多上传一个文件')
    },
    onUploadRemove() {
      this.orderForm.offerInfoTdo.monitorNewFileId = ''
    },



    // 创建监测方案
    createOfferMonitor() {
      this.clearForm()
      this.orderDialogVisible = true
    },

    handleDialogClose(done) {
      this.$confirm('确认离开？')
        .then(_ => {
          done()
        })
        .catch(_ => {})
    },

    // 模糊搜索客户信息
    querySearchAsync(queryString) {
      this.orderForm.offerInfoTdo.consignorName = queryString
      if (queryString && queryString.trim().length > 0) {
        orderServer.findFuzzyQuery(queryString).then(res => {
          if (res.result) {
            this.companyMap = res.result || {}
          }
        }).catch(() => {
        })
      }
    },

    // 根据ID查询客户信息
    handleSelectCom(item) {
      orderServer.findsById(item).then(res => {
        if (res.code === 200 && res.result) {
          this.orderForm.offerInfoTdo = res.result
        }
      })
    },

    // 新逻辑
    addPlanInfo() {
      this.planForm = {
        planName: '',
        checkFreq: '',
        execTimes: 0,
        planTime: '',
        checkFactorCnt: 0,
        checkFee: '',
        sampFee: '',
        factorTdoList: []
      }

      // 默认计划名称
      let resMax = [];
      let pqNumber = 0;
      this.orderForm.offerPlanTdos.forEach(item => {
        var valName = item.planName.substr(0,4);
        var vals = item.planName.substr(4);
        if (valName === '监测计划'){
          var isnum = /^\d+$/.test(vals);
          if (isnum === true){
            resMax.push(parseFloat(vals));
          }
        }
      })
      if (resMax.length !== 0){
        pqNumber = Math.max.apply(null, resMax);
        pqNumber += 1;
      }else {
        pqNumber += 1;
      }
      this.planForm.planName = '监测计划' + pqNumber;
      this.operEditType = false
      this.planInfoVisible = true
    },

    reflushTime() { // 根据不同类型计算计划时长 TODO
      if (this.planForm.checkFreq === '单次') {
        this.planForm.planTime = 1
        this.planForm.scheduleTimes = 1
        this.planForm.execTimes = 1
      } else {
        if (this.planForm.execTimes > 0) {
          const choseObj = this.checkFreqArray.find(i => i.desc === this.planForm.checkFreq)
          if (choseObj) {
            this.planForm.planTime = Number(choseObj.calBaseVal * this.planForm.execTimes / choseObj.calVal).toFixed(1) + '  ' + (choseObj.unit === 'none' ? '' : choseObj.unit)
            this.planForm.scheduleTimes = Number(choseObj.calVal * this.planForm.execTimes).toFixed(0)
          }
        }
      }
    },

    choseGroup() {
      this.currentUUid = uuid.v4().replaceAll('-', '')
      this.cleanAttr = this.currentUUid // 清空弹窗信息的动态触发判定
      this.startFactorGroup = ''
      this.groupAddressArray = []
      this.multiplGroupeSelection = []
      this.choseGroupFatcors = []
      this.factorGroupVisible = true
    },

    handleClearTabs(done) {
      // 数据清空处理
      this.$confirm('确认关闭？').then(_ => {
        done()
      }).catch(_ => {})
    },

    getTabStatus(val) {
      // 数据清空处理
      if (!val) {
        this.factorGroupVisible = false
      }
    },

    getTabResultForSame(val) { // 同系套餐数据获取
      console.log(val, 5565)
      this.$nextTick(() => {
        if (this.planForm.factorTdoList && this.planForm.factorTdoList.length > 0) {
          this.planForm.factorTdoList = this.planForm.factorTdoList.concat(val)
        } else {
          this.planForm.factorTdoList = val
        }
      })
      this.factorGroupVisible = false
    },

    getTabResultForFree(val) { // 自由套餐数据获取
      this.$nextTick(() => {
        if (this.planForm.factorTdoList && this.planForm.factorTdoList.length > 0) {
          this.planForm.factorTdoList = this.planForm.factorTdoList.concat(val)
        } else {
          this.planForm.factorTdoList = val
        }
      })
      this.factorGroupVisible = false
      console.log('自由套餐：' + val)
    },

    addFactor() {
      // 获取UUID
      this.currentUUid = uuid.v4().replaceAll('-', '')
      this.choseFatcors = []
      this.multipleSelection = []
      this.maxTotal = 10
      // this.handleFactorSearch()
      if (this.currentNodeId && this.currentNodeId.length > 0) {
        this.handleFactorSearch()
        if (this.currentNodeId === '002003') { // 厂界无组织/ 环境空气 自动生成5个点位
          this.$nextTick(() => {
            for (var i = 0; i < 4; i++) {
              this.addressArray.push({
                value: '',
                windNum: 3,
                key: Date.now() + i
              })
            }
          })
        } else if (this.currentNodeId === '002001') {
          this.$nextTick(() => {
            for (var i = 0; i < 3; i++) {
              this.addressArray.push({
                value: '',
                windNum: 3,
                key: Date.now() + i
              })
            }
          })
        }
      }
      // 清空设定值
      this.setDay = 1
      this.frequency = 1
      this.addressArray = []
      this.lookPosition = ''
      this.meanType = ''
      this.factorVisible = true
    },

    handleTreeFactorSearch(val, node) {
      this.$refs.multipleTable.clearSelection();
      // console.log(val,node);
      if (val.id.startsWith('004')) {
        this.flag = true
      } else {
        this.flag = false
      }
      if (!val.children || val.children == null) {
        // if (!this.currentNodeId || this.currentNodeId !== val.id) {
        this.addressArray = []
        this.currentNodeId = val.id
        this.currentNodeName = val.name
        this.factorForm.classId = node.parent.data.id
        this.factorForm.secdClassId = val.id
        this.factorForm.factorName = ''
        this.factorForm.pageNumber = 1
        this.handleFactorSearch()
        // 清空已经选择的信息
        this.choseFatcors = []
        this.multipleSelection = []

        if (val.id === '002001' && this.meanType === '0') {
          this.maxTotal = 1
        } else if (val.id === '004001') {
          this.maxTotal = 2
        } else {
          this.maxTotal = 10
        }
        if (val.id === '002003') { // 厂界无组织/ 环境空气 自动生成5个点位
          this.$nextTick(() => {
            for (var i = 0; i < 4; i++) {
              this.addressArray.push({
                value: '',
                windNum: 3,
                key: Date.now() + i
              })
            }
          })
        } else if (val.id === '002001') {
          this.$nextTick(() => {
            for (var i = 0; i < 3; i++) {
              this.addressArray.push({
                value: '',
                windNum: 3,
                key: Date.now() + i
              })
            }
          })
        }
        // }
        // 为底层的时候
      }
    },

    handleFactorSearch() {
      if (this.orderForm.offerInfoTdo.certificationType === '1') {
        this.factorForm.authType = 0
      } else {
        this.factorForm.authType = 1
      }
      if (this.currentNodeId && this.currentNodeId.length > 0) {
        factorServer.getFactorListForPage(this.factorForm).then(res => {
          if (res.code === 200) {
            this.showChoseData = res.result.records || []
            this.factTotal = res.result.total
          }
        })
      }
    },

    handleSelectChange(val, row) {
      // 先判定是否取消
      if (val) {
        if (val.indexOf(row) === -1) {
          const index = this.choseFatcors.findIndex(i => i.id === row.id)
          this.choseFatcors.splice(index, 1)
        }
      }
    },

    handleSelectionChange(val) {
      this.choseFatcors = [];
      this.multipleSelection = val
      if (val) {
        val.forEach(i => {
          const ob = this.choseFatcors.find(j => j.id === i.id)
          if (!ob) {
            this.choseFatcors.push(i)
          }
        })
      }
    },
    //记录每行的key值
    getRowKeys(row) {
      return row.id;
    },

    handleClose(item) {
      // 移除存储的因子
      this.choseFatcors.splice(this.choseFatcors.indexOf(item), 1)
      this.$refs.multipleTable.toggleRowSelection(item, false)
    },

    changeMeanType(val) {
      let curTotal = 0
      if (val === '0') {
        this.maxTotal = curTotal = 1
      } else if (val === '1') {
        this.maxTotal = curTotal = 4
      } else if (val === '2') {
        this.maxTotal = curTotal = 2
      }
      if (this.frequency > curTotal) {
        this.frequency = curTotal
      }
    },

    removeAddDomain(item) {
      var index = this.addressArray.indexOf(item)
      if (index !== -1) {
        this.addressArray.splice(index, 1)
      }
    },

    addAddress() {
      this.$nextTick(() => {
        this.addressArray.push({
          value: '',
          windNum: 3,
          key: Date.now()
        })
      })
    },

    confirmChoseFactor() {
      if (!this.choseFatcors || this.choseFatcors.length <= 0) {
        this.$message.warning('因子不能为空')
        return
      }
      if (!this.lookPosition || this.lookPosition.length <= 0) {
        this.$message.warning('初始检测位置不能为空')
        return
      }
      const dynamic = {}
      if (this.currentNodeId === '002001') {
        this.$set(dynamic, 'meanType', this.meanType)
        this.$set(dynamic, 'meanName', this.MEAN_STATUS[this.meanType])
      }
      let groupId = ''
      if (this.currentNodeId === '002001' || this.currentNodeId === '002003') {
        groupId = this.currentNodeId
      }
      const retListArray = this.choseFatcors.map(i => {
        const { standardNo, standardCode, className, standardName, factorName, price, collectPrice } = i
        const cost = parseFloat(price * this.frequency * this.setDay).toFixed(2)
        const costCP = parseFloat(collectPrice * this.frequency * this.setDay).toFixed(2)
        const n_UUid = uuid.v4().replaceAll('-', '')
        this.$set(i, 'factorGroupKey', n_UUid)
        return {
          checkStandardId: standardCode,
          factorPoint: this.lookPosition.trim(),
          className,
          isFactor: '0',
          secdClassId: this.currentNodeId,
          secdClassName: this.currentNodeName,
          factorName,
          standardNo,
          standardName,
          dayCount: this.setDay,
          frequency: this.frequency,
          totalNum: Number(this.frequency * this.setDay).toFixed(0),
          costPerTime: price, // 单次售价
          totalCost: cost,
          sampFee: collectPrice, // 采样单价
          totalSampFee: costCP,
          meanName: this.currentNodeId === '002001' ? this.MEAN_STATUS[this.meanType] : undefined,
          groupClassId: groupId !== '' ? (groupId + '/' + standardCode) : '',
          dynamicParam: JSON.stringify(dynamic),
          factorGroupKey: n_UUid // 每次添加因子，同组的归为一类
        }
      })
      if (this.addressArray && this.addressArray.length > 0) {
        this.addressArray.forEach(item => {
          if (item.value && item.value.length > 0) {
            this.choseFatcors.forEach(j => {
              const { standardNo, standardCode, className, standardName, factorName, price, collectPrice, factorGroupKey } = j
              const cost = parseFloat(price * this.frequency * this.setDay).toFixed(2)
              const costCP = parseFloat(collectPrice * this.frequency * this.setDay).toFixed(2)
              retListArray.push({
                checkStandardId: standardCode,
                factorPoint: item.value.trim(),
                className,
                isFactor: '0',
                secdClassId: this.currentNodeId,
                secdClassName: this.currentNodeName,
                factorName,
                standardNo,
                standardName,
                dayCount: this.setDay,
                frequency: this.frequency,
                totalNum: Number(this.frequency * this.setDay).toFixed(0),
                costPerTime: price, // 单次售价
                totalCost: cost,
                sampFee: collectPrice, // 采样单价
                totalSampFee: costCP,
                remark: '',
                meanName: this.currentNodeId === '002001' ? this.MEAN_STATUS[this.meanType] : undefined,
                groupClassId: groupId !== '' ? (groupId + '/' + standardCode) : '',
                dynamicParam: JSON.stringify(dynamic),
                factorGroupKey // 每次添加因子，同组的归为一类
              })
            })
          }
        })
      }
      // 追加合并
      this.$nextTick(() => {
        if (this.planForm.factorTdoList && this.planForm.factorTdoList.length > 0) {
          this.planForm.factorTdoList = this.planForm.factorTdoList.concat(retListArray)
        } else {
          this.planForm.factorTdoList = retListArray
        }
      })
      this.$refs.multipleTable.clearSelection();
      this.factorVisible = false
    },

    getPlanSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计'
          return
        }
        const values = data.map(item => {
          if (column.label === '次数') {
            return Number(item.dayCount * item.frequency)
          } else if (column.label === '检测费（元）') {
            return parseFloat(item.dayCount * item.frequency * item.costPerTime)
          } else if (column.label === '采样费（元）') {
            return parseFloat(item.dayCount * item.frequency * item.sampFee)
          } else if (column.label === '检测费总计（元）') {
            return parseFloat(item.dayCount * item.frequency * item.costPerTime)
          } else if (column.label === '采样费总计（元）') {
            return parseFloat(item.dayCount * item.frequency * item.sampFee)
          } else {
            return Number(item[column.property])
          }
        })
        if (!values.every(value => isNaN(value))) {
          if (index === 6) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
          } else if (index === 8) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
          } else if (index === 10) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0).toFixed(2)
          } else if (index === 12) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0).toFixed(2)
          }
        } else {
          sums[index] = ''
        }
      })
      return sums
    },

    reflushMoney(row) {
      row.totalNum = Number(row.dayCount * row.frequency)
      row.totalCost = Number(row.dayCount * row.frequency * row.costPerTime).toFixed(2)
      row.totalSampFee = Number(row.dayCount * row.frequency * row.sampFee).toFixed(2)
    },

    handleRowDel(index, row) {
      this.planForm.factorTdoList.splice(index, 1)
    },

    handleCancle() {
      this.planInfoVisible = false
    },

    confimPlanInfo() { // 新增计划
      if (this.planForm.planName === '' || this.planForm.checkFreq === undefined || this.planForm.checkFreq === '') {
        this.$message.error('请完善计划基础信息')
        return
      }
      if (!this.planForm.factorTdoList || this.planForm.factorTdoList.length === 0) {
        this.$message.error('因子信息不能为空')
        return
      }
      if (this.planForm.execTimes <= 0) {
        this.$message.error('计划执行次数不能小于1！')
        return
      }
      var totalPriceInfo = 0
      var totalCollectPriceInfo = 0
      var totalCount = 0
      var checkFactors = []
      var checkFactorNames = []
      var factorList = this.planForm.factorTdoList.map(m => {
        totalPriceInfo = parseFloat(totalPriceInfo) + parseFloat(m.frequency * m.dayCount * m.costPerTime)
        totalCollectPriceInfo = parseFloat(totalCollectPriceInfo) + parseFloat(m.frequency * m.dayCount * m.sampFee)
        totalCount = parseFloat(totalCount) + parseFloat(m.frequency * m.dayCount)
        const item = {
          checkStandardId: m.checkStandardId ? m.checkStandardId : m.standardCode,
          isFactor: m.isFactor,
          factorName: m.factorName,
          secdClassId: m.secdClassId,
          frequency: m.frequency,
          dayCount: m.dayCount,
          factorGroupKey: m.factorGroupKey,
          costPerTime: m.costPerTime,
          sampFee: m.sampFee,
          factorPoint: m.factorPoint.trim(),
          standardNo: m.standardNo,
          dynamicParam: m.dynamicParam,
          remark: m.remark,
          secdClassName: m.secdClassName,
          meanName: m.meanName,
          totalCost: m.totalCost,
          totalSampFee: m.totalSampFee,
          standardName: m.standardName,
          totalNum: m.totalNum,
          className: m.className,
          subCheckStandardIds: m.subCheckStandardIds ? m.subCheckStandardIds : []
        }
        if (m.subCheckStandards) {
          const subCheckStandards = m.subCheckStandards.map(j => j.standardCode)
          this.$set(item, 'subCheckStandardIds', subCheckStandards)
        }
        // 因子信息校验
        const obj = checkFactors.find(i => (i.factorPoint === m.factorPoint && i.secdClassName === m.secdClassName && i.factorName === m.factorName && i.standardNo === m.standardNo))
        if (!obj) {
          checkFactors.push(m)
        } else {
          checkFactorNames.push(m.factorName)
        }
        return item
      })

      if (checkFactorNames.length > 0) {
        this.$message.error('在一个监测计划内，同一检测位置、同一检测类别下具有相同标准号的检测因子不能重复添加！')
        return
      }
      var offerPlan = {
        planName: this.planForm.planName,
        checkFreq: this.planForm.checkFreq,
        execTimes: this.planForm.execTimes,
        planTime: this.planForm.planTime,
        scheduleTimes: this.planForm.scheduleTimes,
        checkFactorCnt: totalCount,
        checkFee: totalPriceInfo,
        sampFee: totalCollectPriceInfo,
        factorTdoList: factorList
      }
      if (this.operEditType) {
        this.currentRow.planName = this.planForm.planName
        this.currentRow.checkFreq = this.planForm.checkFreq
        this.currentRow.execTimes = this.planForm.execTimes
        this.currentRow.planTime = this.planForm.planTime
        this.currentRow.scheduleTimes = this.planForm.scheduleTimes
        this.currentRow.checkFactorCnt = totalCount
        this.currentRow.checkFee = totalPriceInfo
        this.currentRow.sampFee = totalCollectPriceInfo
        this.currentRow.factorTdoList = factorList
        this.planInfoVisible = false
        return
      }
      this.orderForm.offerPlanTdos.push(offerPlan)
      this.planInfoVisible = false
    },

    planSearch(row) { // 计划因子查看
      this.showPlanForm = Object.assign({}, row)
      this.planDetailVisible = true
    },

    planUpdate(row) { // 计划因子修改
      this.currentRow = row
      this.operEditType = true
      this.planForm = {
        planName: '',
        checkFreq: '',
        execTimes: 0,
        planTime: '',
        checkFactorCnt: 0,
        checkFee: '',
        sampFee: '',
        factorTdoList: []
      }
      this.planForm = Object.assign({}, row)
      this.planForm.factorTdoList = [...row.factorTdoList]
      this.planInfoVisible = true
    },

    planDelete(index) { // 计划删除
      if (index !== -1) {
        this.orderForm.offerPlanTdos.splice(index, 1)
      }
      // 当计划为空清除费用统计
      if (this.orderForm.offerPlanTdos.length === 0){
        this.orderForm.offerCostTdo.checkAmount = 0.00;   // 检测费合计
        this.orderForm.offerCostTdo.reportAmount = 0.00;  // 报告编制费
        this.orderForm.offerCostTdo.reportAmountRate = 10;  // 报告编制费率
        this.orderForm.offerCostTdo.expediteAmount = 0.00;   // 报告加急费
        this.orderForm.offerCostTdo.laborAmount = 0.00;   // 人工费/采样费
        this.orderForm.offerCostTdo.tripAmount = 0.00;   // 差旅费
        this.orderForm.offerCostTdo.taxAmount = 0.00;   // 增值税金额
        this.orderForm.offerCostTdo.taxAmountRate = 6;   // 增值税率
        this.orderForm.offerCostTdo.sysAmount = 0.00;   // 系统价格
        this.orderForm.offerCostTdo.discountRate = 0.00;   // 检测优惠率
        this.orderForm.offerCostTdo.draftAmount = 0.00;   // 优惠价
        this.otherPrice = 0.00;   // 额外费用
        this.checkCostRate = 0;   // 折扣率
      }
    },

    // 报价单新增提交
    confirmDialog() {
      if (this.orderForm.offerPlanTdos && this.orderForm.offerPlanTdos.length > 0) {
        const objFlag = this.orderForm.offerPlanTdos.find(j => j.factorPoint === '')
        if (objFlag) {
          this.$message.warning('因子位置信息不能为空')
          return
        }
        this.orderForm.offerInfoTdo.province = this.provinceOne
        this.orderForm.offerInfoTdo.city = this.cityOne;
        this.orderForm.offerInfoTdo.county = this.countyOne;
        this.confirmCreate()
      } else {
        this.$message.warning('因子信息不能为空')
      }
    },

    confirmCreate() {
      this.$refs.orderForm.validate(valid => {
        if (valid) {
          const data = {
            offerInfoTdo: this.orderForm.offerInfoTdo,
            offerPlanTdos: this.orderForm.offerPlanTdos.map(i => {
              const { planName, checkFreq, execTimes, planTime, scheduleTimes, checkFactorCnt, checkFee ,sampFee } = i
              const factorList = i.factorTdoList.map(j => {
                const { checkStandardId, isFactor, factorName, secdClassId, frequency, dayCount, costPerTime, sampFee, factorPoint, remark, dynamicParam, factorGroupKey, subCheckStandardIds } = j
                return {
                  checkStandardId, isFactor, factorName, secdClassId, frequency, dayCount, costPerTime, sampFee, factorPoint: factorPoint.trim(), remark, dynamicParam, factorGroupKey, subCheckStandardIds
                }
              })
              return { planName, checkFreq, execTimes, planTime, scheduleTimes, checkFactorCnt, checkFee, sampFee, factorTdoList: factorList }
            })
          }
          // 新增报价单
          offermonitorServer.saveOfferMonitor(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: '成功',
                message: result.message,
                type: 'success'
              })
              this.handleSearch()
              this.orderDialogVisible = false
              this.$refs.orderForm.resetFields()
              this.$refs.upload.uploadFiles.splice(0, 1);
            } else {
              this.$notify({
                title: '失败',
                message: result.message,
                type: 'error'
              })
            }
          }).catch(() => {})
        } else {
          this.$message.warning('请完善必填信息')
          return false
        }
      })
    },


//**********************************************  编辑监测方案  **************************************************

    updateOfferMonitorScheme(row, item) {
      this.sourceStatus = item.sourceStatus
      this.orderForm.monitorSchemeId = row.id
      this.offerIdAddorUpdate = item.offerId
      this.getsTaskCode()
      offermonitorServer.findOfferDetailByMonitorSchemeId(row.id).then(res => {
        if (res.code === 200) {
          this.orderForm.offerInfoTdo = res.result.offerBaseVo || {}
          //关联任务单号
          if (res.result.offerBaseVo.relationTaskCode !== null){
            if (res.result.offerBaseVo.relationTaskCode === ''){
              this.relationTaskCodeUpdate = null
            }else {
              this.relationTaskCodeUpdate = res.result.offerBaseVo.relationTaskCode.split(',')
            }
          }
          if (res.result.costVo === null){
            this.orderForm.offerCostTdo.checkAmount = 0
            this.orderForm.offerCostTdo.reportAmount = 0
            this.orderForm.offerCostTdo.reportAmountRate = 10
            this.orderForm.offerCostTdo.expediteAmount = 0
            this.orderForm.offerCostTdo.laborAmount = 0
            this.orderForm.offerCostTdo.tripAmount = 0
            this.orderForm.offerCostTdo.taxAmount = ''
            this.orderForm.offerCostTdo.taxAmountRate = 6
            this.orderForm.offerCostTdo.sysAmount = 0
            this.orderForm.offerCostTdo.discountRate = ''
            this.orderForm.offerCostTdo.draftAmount = 0
          }else {
            this.orderForm.offerCostTdo = res.result.costVo || {}
          }
          this.orderForm.selfCostTdos = res.result.selfCostVos || []
          if (res.result.offerPlanVos != null) {
            this.orderForm.offerPlanTdos = res.result.offerPlanVos.map(i => {
              if (i.planFactorVoList && i.planFactorVoList.length > 0) {
                i.planFactorVoList.forEach(j => {
                  if (j.dynamicParam !== '{}' && j.dynamicParam.indexOf('meanName') > -1) {
                    const dynParam = JSON.parse(j.dynamicParam)
                    this.$set(j, 'meanName', dynParam.meanName)
                  }
                  let subCheckStandardIds = []
                  if (j.factorSubSetVos && j.factorSubSetVos.length > 0) {
                    subCheckStandardIds = j.factorSubSetVos.map(m => m.checkStandardId)
                  }
                  this.$set(j, 'subCheckStandardIds', subCheckStandardIds)
                })
                this.$set(i, 'factorTdoList', i.planFactorVoList)
              }
              return i
            }) || [] // 处理展示meanName
          } else {
            this.orderForm.offerPlanTdos = []
          }
          this.orderDialogUpdateVisible = true
        }
      })
    },

    // 修改监测方案信息
    confirmUpdateDialog() {
      if (this.orderForm.offerPlanTdos && this.orderForm.offerPlanTdos.length > 0) {
        const objFlag = this.orderForm.offerPlanTdos.find(j => j.factorPoint === '')
        if (objFlag) {
          this.$message.warning('因子位置信息不能为空')
          return
        }
        // 关联任务单号
        if (this.relationTaskCodeUpdate !== null){
          this.orderForm.offerInfoTdo.relationTaskCode = this.relationTaskCodeUpdate.join(',');
        }
        this.confirmUpdateCreate()
      } else {
        this.$message.warning('因子信息不能为空')
      }
    },

    confirmUpdateCreate() {
      this.$refs.orderUpdateForm.validate(valid => {
        if (valid) {
          const data = {
            monitorSchemeId: this.orderForm.monitorSchemeId,
            offerInfoTdo: this.orderForm.offerInfoTdo,
            offerPlanTdos: this.orderForm.offerPlanTdos.map(i => {
              const { planName, checkFreq, execTimes, planTime, scheduleTimes, checkFactorCnt, checkFee ,sampFee } = i
              const factorList = i.factorTdoList.map(j => {
                const { checkStandardId, isFactor, factorName, secdClassId, frequency, dayCount, costPerTime, sampFee, factorPoint, remark, dynamicParam, factorGroupKey, subCheckStandardIds } = j
                return {
                  checkStandardId, isFactor, factorName, secdClassId, frequency, dayCount, costPerTime, sampFee, factorPoint: factorPoint.trim(), remark, dynamicParam, factorGroupKey, subCheckStandardIds
                }
              })
              return { planName, checkFreq, execTimes, planTime, scheduleTimes, checkFactorCnt, checkFee, sampFee, factorTdoList: factorList }
            })
          }
          // 修改监测方案信息
          offermonitorServer.modifyOfferMonitor(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: '成功',
                message: result.message,
                type: 'success'
              })
              this.handleSearch()
              this.orderDialogUpdateVisible = false
              this.$refs.orderUpdateForm.resetFields()
              this.$refs.uploadUpdate.uploadFiles.splice(0, 1);
            } else {
              this.$notify({
                title: '失败',
                message: result.message,
                type: 'error'
              })
            }
          }).catch(() => {})
        } else {
          this.$message.warning('请完善必填信息')
          return false
        }
      })
    },

 //**********************************************  新增监测方案(只添加方案，不添加项目)  **************************************************

    addOfferMonitorScheme(row) {
      this.sourceStatus = row.sourceStatus
      this.orderForm.offerPlanTdos = []
      this.orderForm.offerCostTdo = {}
      this.orderForm.selfCostTdos = []
      this.relationTaskCodeUpdate = null
      this.monitorId = row.id
      this.offerIdAddorUpdate = row.offerId
      this.getsTaskCode()
      offermonitorServer.findOfferByMonitorId(row.id).then(res => {
        if (res.code === 200) {
          this.orderForm.offerInfoTdo = res.result.offerBaseVo || {}
          this.orderDialogAddVisible = true
        }
      })
    },

    // 新增监测方案(只添加方案，不添加项目)
    confirmAddDialog() {
      if (this.orderForm.offerPlanTdos && this.orderForm.offerPlanTdos.length > 0) {
        const objFlag = this.orderForm.offerPlanTdos.find(j => j.factorPoint === '')
        if (objFlag) {
          this.$message.warning('因子位置信息不能为空')
          return
        }
        // 关联任务单号
        if (this.relationTaskCodeUpdate !== null){
          this.orderForm.offerInfoTdo.relationTaskCode = this.relationTaskCodeUpdate.join(',');
        }
        this.confirmAddCreate()
      } else {
        this.$message.warning('因子信息不能为空')
      }
    },

    confirmAddCreate() {
      this.$refs.orderAddForm.validate(valid => {
        if (valid) {
          const data = {
            monitorId: this.monitorId,
            offerInfoTdo: this.orderForm.offerInfoTdo,
            offerPlanTdos: this.orderForm.offerPlanTdos.map(i => {
              const { planName, checkFreq, execTimes, planTime, scheduleTimes, checkFactorCnt, checkFee ,sampFee } = i
              const factorList = i.factorTdoList.map(j => {
                const { checkStandardId, isFactor, factorName, secdClassId, frequency, dayCount, costPerTime, sampFee, factorPoint, remark, dynamicParam, factorGroupKey, subCheckStandardIds } = j
                return {
                  checkStandardId, isFactor, factorName, secdClassId, frequency, dayCount, costPerTime, sampFee, factorPoint: factorPoint.trim(), remark, dynamicParam, factorGroupKey, subCheckStandardIds
                }
              })
              return { planName, checkFreq, execTimes, planTime, scheduleTimes, checkFactorCnt, checkFee, sampFee, factorTdoList: factorList }
            })
          }
          // 修改监测方案信息
          offermonitorServer.saveOfferMonitorScheme(data).then(result => {
            if (result.code === 200) {
              this.$notify({
                title: '成功',
                message: result.message,
                type: 'success'
              })
              this.handleSearch()
              this.orderDialogAddVisible = false
              this.$refs.orderAddForm.resetFields()
              this.$refs.uploadAdd.uploadFiles.splice(0, 1);
            } else {
              this.$notify({
                title: '失败',
                message: result.message,
                type: 'error'
              })
            }
          }).catch(() => {})
        } else {
          this.$message.warning('请完善必填信息')
          return false
        }
      })
    },

//**********************************************  复制  **************************************************

    // 复制监测方案
    copyOfferInfosMonitorScheme(monitorSchemeId) {
      this.$confirm("确定复制吗?", '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        offermonitorServer.copyOfferInfoMonitorScheme(monitorSchemeId).then(result => {
          if (result.code === 200) {
            this.$notify({
              title: '成功',
              message: result.message,
              type: 'success'
            })
            this.handleSearch()
          } else {
            this.$notify({
              title: '失败',
              message: result.message,
              type: 'error'
            })
          }
        })
      }).catch(() => {})
    },

    // 删除监测方案
    deleteOfferInfosMonitorScheme(monitorSchemeId) {
      this.$confirm("确定删除吗?", '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const data = { monitorSchemeId: monitorSchemeId };
        offermonitorServer.deleteOfferInfoMonitorScheme(data).then(result => {
          if (result.code === 200) {
            this.$notify({
              title: '成功',
              message: result.message,
              type: 'success'
            })
            this.handleSearch()
          } else {
            this.$notify({
              title: '失败',
              message: result.message,
              type: 'error'
            })
          }
        })
      }).catch(() => {})
    },

    // 查询参与评审人员
    submitOfferInfoMonitorUser(row) {
      if (row.schemeUserId === null){
        this.$message.error('请完善方案！')
        return
      }
      this.monitorUserId = []
      this.monitorSchemeId = row.id
      offermonitorServer.findOfferInfoMonitorUser().then(res => {
        if (res.code === 200 && res.result) {
          this.monitorUserData = res.result || []
        }
        this.lookMonitorUserVisible = true
      })
    },

    handleUserSelectionChange(val) {
      this.monitorUserId = val
    },

    // 保存提交评审
    confirmMonitorUser() {
      const userIds = []
      this.monitorUserId.map((item) => {
        userIds.push(item.userId)
      })
      if (userIds.length === 0) {
        this.$message.error('请选择评审人员')
        return
      }
      const data = {
        monitorSchemeId: this.monitorSchemeId,
        reviewerUserId: userIds.join(',')
      };
      offermonitorServer.checkJudgeRecordMonitor(data).then(res => {
        if (res.code === 200) {
          this.$notify({
            title: '成功',
            message: res.message,
            type: 'success'
          })
          this.lookMonitorUserVisible = false;
          this.handleSearch();
        } else {
          this.$notify({
            title: '失败',
            message: res.message,
            type: 'error'
          })
        }
      })
    },

    // 评审进度查看
    findReviewSchedule(row) {
      this.reviewScheduleData = []
      offermonitorServer.findReviewSchedule(row.id).then(res => {
        if (res.code === 200 && res.result) {
          this.reviewScheduleData = res.result || []
        }
        this.seeMonitorUserVisible = true
      })
    },

    onUploadMonitorSchemeChange(file) {
      if (file.status === 'ready') return
      if (file.status === 'success') {
        const res = file.response || {}
        if (res && res.code === 200) {
          this.$message({
            type: 'success',
            message: '上传成功!'
          })
          this.handleSearch()
        } else {
          this.$message.error('上传失败!')
        }
      } else {
        this.$message.error('上传失败!')
      }
    },

    // 原始方案下载
    downloadMonScheme(row) {
      if (row.monitorFileId !== null && row.monitorFileId.length > 0) {
        var url = this.$store.getters.sysBaseUrl + '/file/ht/upload/' + row.monitorFileId
        window.open(url)
      } else {
        this.$message.error('原始方案为空！')
      }
    },

    // 最新方案下载
    downloadMonSchemeLast(row) {
      if (row.monitorNewFileId !== null && row.monitorNewFileId.length > 0) {
        var url = this.$store.getters.sysBaseUrl + '/file/ht/upload/' + row.monitorNewFileId
        window.open(url)
      } else {
        this.$message.error('最新方案为空！')
      }
    },

  }
}
</script>

<style scoped lang="scss" type="text/scss">
.search_div {
  >div {
    &:nth-child(1){
      margin-right: 10px;
    }
    display: inline-block;
  }
}
.search_input {
  width: 200px;
  margin-bottom: 5px;
}
.search-right {
  text-align: right;
  padding-right: 25px;
}
.item {
  font-size: 16px;
}
::v-deep .el-card .el-card__header {
  padding: 5px 20px;
  background: #F3F2F2;
}
.block-flex {
  position: relative;
  display: flex;
  &>div{
    border: 1px solid #B7B7B7;
    width: 100px;
    margin: 0;
    line-height: 30px;
    text-align: center;
  }
  &>div:first-child {
    background: #B7B7B7;
  }
}
.card-left {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.card-right {
  width: 100%;
  min-height: 200px;
  max-height: 450px;
}
.el-card {
  overflow: auto;
}
.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
.el-icon-arrow-down {
  font-size: 14px;
}
// /deep/.main-body .el-table__header-wrapper  .el-checkbox{
//   display:none
// }
.agreement_picture {
  min-height: calc(100%);
  .pdf{
    height: calc(100%);
  }
}

/deep/ .el-input.is-disabled .el-input__inner {
  color:unset
}

/deep/.i-input .el-input__inner {
  text-align: center;
}

/deep/.right-input .el-input__inner {
  text-align: right;
}

.el-header {
  line-height: 45px;
  height: 45px;
}
.el-footer {
  text-align: right;
  line-height: 45px;
  height: 45px;

  .pagination-container {
    padding: 0;
    margin-top: 10px;
    margin-bottom: 45px;
  }
}
.el-main {
  overflow-y: auto;
}
.el-container {
  max-height: 450px;
}
</style>
<style scoped>
 .text {
   font-size: 14px;
 }
.dialog-item {
  padding-left: 3px;
  line-height: 30px;
  cursor:pointer;

}
.dialog-item:hover {
  background: #e8f4ff;
  border-radius: 3px;
}

table {
  background-color: transparent
}

caption {
  padding-top: 8px;
  padding-bottom: 8px;
  color: #777;
  text-align: left
}

th {
  text-align: left
}

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: 20px
}

.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: middle;
  border-top: 1px solid #ddd
}

.table>thead>tr>th {
  vertical-align: bottom;
  border-bottom: 2px solid #ddd
}

.table>caption+thead>tr:first-child>td,.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>td,.table>thead:first-child>tr:first-child>th {
  border-left: 1px solid #F1F2F4
}

.table>tbody+tbody {
  border-top: 2px solid #ddd
}

.table .table {
  background-color: #fff
}

.table-condensed>tbody>tr>td,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>td,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>thead>tr>th {
  padding: 5px
}

.table-bordered {
  border: 1px solid #ddd
}

.table-bordered>tbody>tr>td,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>td,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>thead>tr>th {
  border: 1px solid #ddd
}

.table-bordered>thead>tr>td,.table-bordered>thead>tr>th {
  border-bottom-width: 2px
}

.table-striped>tbody>tr:nth-of-type(odd) {
  background-color: #f9f9f9
}

.table-hover>tbody>tr:hover {
  background-color: #f5f5f5
}

table col[class*=col-] {
  position: static;
  display: table-column;
  float: none
}

table td[class*=col-],table th[class*=col-] {
  position: static;
  display: table-cell;
  float: none
}

.table>tbody>tr.active>td,.table>tbody>tr.active>th,.table>tbody>tr>td.active,.table>tbody>tr>th.active,.table>tfoot>tr.active>td,.table>tfoot>tr.active>th,.table>tfoot>tr>td.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>thead>tr.active>th,.table>thead>tr>td.active,.table>thead>tr>th.active {
  background-color: #f5f5f5
}

.table-hover>tbody>tr.active:hover>td,.table-hover>tbody>tr.active:hover>th,.table-hover>tbody>tr:hover>.active,.table-hover>tbody>tr>td.active:hover,.table-hover>tbody>tr>th.active:hover {
  background-color: #e8e8e8
}

.table>tbody>tr.success>td,.table>tbody>tr.success>th,.table>tbody>tr>td.success,.table>tbody>tr>th.success,.table>tfoot>tr.success>td,.table>tfoot>tr.success>th,.table>tfoot>tr>td.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>thead>tr.success>th,.table>thead>tr>td.success,.table>thead>tr>th.success {
  background-color: #dff0d8
}

.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr.success:hover>th,.table-hover>tbody>tr:hover>.success,.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover {
  background-color: #d0e9c6
}

.table>tbody>tr.info>td,.table>tbody>tr.info>th,.table>tbody>tr>td.info,.table>tbody>tr>th.info,.table>tfoot>tr.info>td,.table>tfoot>tr.info>th,.table>tfoot>tr>td.info,.table>tfoot>tr>th.info,.table>thead>tr.info>td,.table>thead>tr.info>th,.table>thead>tr>td.info,.table>thead>tr>th.info {
  background-color: #d9edf7
}

.table-hover>tbody>tr.info:hover>td,.table-hover>tbody>tr.info:hover>th,.table-hover>tbody>tr:hover>.info,.table-hover>tbody>tr>td.info:hover,.table-hover>tbody>tr>th.info:hover {
  background-color: #c4e3f3
}

.table>tbody>tr.warning>td,.table>tbody>tr.warning>th,.table>tbody>tr>td.warning,.table>tbody>tr>th.warning,.table>tfoot>tr.warning>td,.table>tfoot>tr.warning>th,.table>tfoot>tr>td.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>thead>tr.warning>th,.table>thead>tr>td.warning,.table>thead>tr>th.warning {
  background-color: #fcf8e3
}

.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr.warning:hover>th,.table-hover>tbody>tr:hover>.warning,.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover {
  background-color: #faf2cc
}

.table>tbody>tr.danger>td,.table>tbody>tr.danger>th,.table>tbody>tr>td.danger,.table>tbody>tr>th.danger,.table>tfoot>tr.danger>td,.table>tfoot>tr.danger>th,.table>tfoot>tr>td.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>thead>tr.danger>th,.table>thead>tr>td.danger,.table>thead>tr>th.danger {
  background-color: #f2dede
}

.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr.danger:hover>th,.table-hover>tbody>tr:hover>.danger,.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover {
  background-color: #ebcccc
}

.table-responsive {
  min-height: 3.01%;
  overflow-x: auto;
}

.table-bordered, .table-bordered > tbody > tr > td, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > td, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > thead > tr > th {
  border: 1px solid #e9ecef;
  text-align: center;
  line-height: 14px;
}

.table-bordered, td, th {
  border-radius: 0 !important;
}

.table-bordered > tbody > tr:last-child > td {
  border-bottom: 1px solid #e9ecef;
}

.bootstrap-table .fixed-table-container .fixed-table-header {
  overflow: hidden;
  background: rgba(0, 0, 0, .05);
}

.fixed-table-header .table > thead > tr {
  background: none !important;
}

.table > thead > tr {
  color: #636363;
  font-weight: 400;
  background: rgba(0, 0, 0, .05);
  /*   background: repeat-x #fafafa;
background-image: -webkit-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
background-image: -o-linear-gradient(top,#F8F8F8 0,#fafafa 100%);
background-image: linear-gradient(to bottom,#F8F8F8 0,#fafafa 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff8f8f8', endColorstr='#ffececec', GradientType=0); */
}

.table > thead > tr > th {
  border-color: #e9ecef;
  font-weight: 700;
  border-right-color: transparent;
}

.table > thead > tr > th .ace-icon:first-child {
  margin-right: 2px;
}

.table > thead > tr > th:first-child {
  border-left-color: #F1F1F1;
}

.table > thead > tr > th:last-child {
  border-right-color: #F1F1F1;
}

.table.table-bordered > thead > tr > th {
  vertical-align: middle;
}

td.center, th.center {
  text-align: center;
}

td .lbl, th .lbl {
  margin-bottom: 0;
}

td .lbl:only-child, th .lbl:only-child {
  vertical-align: top;
}

.table-header {
  background-color: #307ECC;
  color: #FFF;
  font-size: 14px;
  line-height: 38px;
  padding-left: 12px;
  margin-bottom: 1px;
}

.table-header .close {
  margin-right: 8px;
  margin-top: 0;
  opacity: .45;
  filter: alpha(opacity=45);
}

.table-header .close:hover {
  opacity: .75;
  filter: alpha(opacity=75);
}

th.detail-col {
  width: 48px;
  text-align: center;
}

tr.detail-row {
  display: none;
}

tr.detail-row.open {
  display: block;
  display: table-row;
}

tr.detail-row > td {
  background-color: #f1f6f8;
  border-top: 3px solid #d1e1ea !important;
}

.table-detail {
  background-color: #fff;
  border: 1px solid #dcebf7;
  width: 100%;
  padding: 12px;
}

.table-detail td > .profile-user-info {
  width: 100%;
}

 .el-button{
   user-select: unset;
 }
 .apostrophe{
   text-overflow: ellipsis;
   overflow: hidden;
   white-space: nowrap;
 }
 /deep/ .el-upload-dragger{
   background-color: #fff;
   border: 1px dashed #d9d9d9;
   border-radius: 6px;
   box-sizing: border-box;
   width: 360px;
   height: 42px;
   text-align: center;
   cursor: pointer;
   position: relative;
   overflow: hidden;
 }

</style>
